/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: dings
 * Date: 2024-06-01
 * Time: 18:29
 */

public class Solution {
    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     *
     *
     * @param str string字符串
     * @return string字符串
     */
    public String setstring (String str) {
        // write code here
        int len = str.length();
        int[] arr = new int[200];
        char[] arr1 = new char[52];
        for (int i = 0; i < len; i++) {
            int index = str.charAt(i);
            arr[index]++;
        }
        int j = 0;
        for (int i = 0; i < len; i++) {
            int value = str.charAt(i);
            if(arr[value] != 0) {
                arr1[j] = (char)(value);
                j++;
                arr[value] = 0;
            }
        }
        int count = 0;
        for (int i = 0; i < arr1.length; i++) {
            if(arr1[i] != 0) {
                count++;
            }
        }
        char[] arr2 = new char[count];
        for (int i = 0; i < count; i++) {
            arr2[i] = arr1[i];
        }
        String ret = new String(arr2);
        return ret;
    }

    public static void main(String[] args) {
        String str = "bhsHbgg";
        Solution solution = new Solution();
        String ret = solution.setstring(str);
        System.out.println(ret);
    }
}